#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdio.h>
#include<unistd.h>

#define LOG "log.txt"

int main()
{
    //简单使用系统调用，完成w,a
    //umask(0);
    close(1);
    int fd = open(LOG,O_CREAT | O_WRONLY | O_TRUNC,0666);
    printf("you can see me\n"); 
    printf("you can see me\n");
    printf("you can see me\n");
    printf("you can see me\n");
    fprintf(stdout,"you can see me\n");
    fprintf(stdout,"you can see me\n");
    fprintf(stdout,"you can see me\n");
    //int fd = open(LOG, O_CREAT | O_WRONLY | O_APPEND ,0666);
     //int fd = open(LOG,O_RDONLY);
     // if(fd == -1)
     // {
     //     perror("open file"); 
     //     exit(1);
     // }
     // printf("fd : %d ,open sucessful\n",fd);
     //
     // char s[128] = "hello world"; 
     // int cnt = 5;
     // while(cnt)
     // {
     //     char mess[256] = {0};
     //     snprintf(mess,sizeof(mess),"%s,%d\n",s,cnt--);
     //     write(fd,mess,strlen(mess));
     // } 

      //char mess[256] = {0};
      //size_t n = read(fd,mess,sizeof(mess)-1);//留出一个位置填\0
      //if(n > 0)
      //{
      //    mess[n] = '\0';
      //}
      //
      //printf("%s",mess);

      return 0;

}

